
<form  id="form" role="form" class="epii" method="post" data-form="1" action="">


    <div class="row">
        <div class="col-3"></div>
        <div class="col-6">
            <div class="card card-default">

                <div class="card-header">
                    <h3 class="card-title">预约设置</h3>
                </div>
                <div class="card-body">

                    <div class="form-group">
                        <label>&nbsp;</label>
                        <span style="color: red;">预约数量为每个时间段可预约数量;<br/>预约天数为可预约的天数;<br/>提前预约小时为须提前多少小时预约。</span>
                    </div>

                    <div class="form-group">
                        <label>预约数量设置：</label>
                        <input type="number" class="form-control" name="num" value="{? $setting.num}" required placeholder="请输入预约数量">
<!--                        <small id="" class="form-text text-muted">预约数量为每个时间段可预约数量</small>-->
                    </div>

                    <div class="form-group">
                        <label>预约天数设置：</label>
                        <input type="number" class="form-control" name="day" value="{? $setting.day}" required placeholder="请输入预约天数">
<!--                        <small id="" class="form-text text-muted">预约天数为可预约的天数</small>-->
                    </div>

                    <div class="form-group">
                        <label>提前预约小时：</label>
                        <input type="number" class="form-control" name="hour" value="{? $setting.hour}" required placeholder="请输入提前预约小时">
<!--                        <small id="" class="form-text text-muted">提前预约小时为须提前多少小时预约</small>-->
                    </div>

                </div>
            </div>
        </div>
        <div class="col-3"></div>
    </div>



    <div id="vallist">
        <div class="row">
            <div class="col-3"></div>
            <div class="col-6">
                <div class="card card-default">

                    <div class="card-header">
                        <h3 class="card-title">时间段设置</h3>
                    </div>

                    <div class="card-body">
        <?php if($list){ ?>



            <?php foreach($list as $val){ ?>
                    <div class="row onerow">
                        <div class="col-1"></div>
                        <div class="col-5">
                            <div class="form-group">
                                <label>开始时间：</label>
                                <input type="time" class="form-control" name="start[]" value="{$val['start']}" required placeholder="请输入开始时间" />
                            </div>
                        </div>
                        <div class="col-5">
                            <div class="form-group">
                                <label>结束时间：</label>
                                <input type="time" class="form-control" name="end[]" value="{$val['end']}" required placeholder="请输入结束时间" />
                            </div>
                        </div>
                        <div class="col-1"><span class="card-tools" style="color:red;cursor: pointer;" onclick="del(this);">删除</span></div>

                    </div>
            <?php } ?>
        <?php }else{ ?>
            <div class="row onerow">

                <div class="col-1"></div>
                <div class="col-5">
                    <div class="form-group">
                        <label>开始时间：</label>
                        <input type="time" class="form-control" name="start[]" value="" required placeholder="请输入开始时间" />
                    </div>
                </div>
                <div class="col-5">
                    <div class="form-group">
                        <label>结束时间：</label>
                        <input type="time" class="form-control" name="end[]" value="" required placeholder="请输入结束时间" />
                    </div>
                </div>
                <div class="col-1"><span class="card-tools" style="color:red;cursor: pointer;" onclick="del(this);">删除</span></div>
            </div>
        <?php } ?>

                        </div>
                    </div>
                </div>
            <div class="col-3"></div>
            </div>
    </div>


    <div class="row">
        <div class="col-4"></div>
        <div class="col-4">
            <a class="btn btn-outline-primary" href="javascript:void(0)" id="addval" title="添加"><i class="fa fa-plus"></i>添加</a>
        </div>
        <div class="col-4"></div>
    </div>

    <div class="row">
        <div class="col-8"></div>
        <div class="col-1">
            <div class="form-footer">
                <button  type="submit" class="btn btn-primary">提交</button>
            </div>
        </div>
        <div class="col-3">

        </div>
    </div>

</form>



<div id="tpl" style="display: none;">
    <div class="row onerow">

        <div class="col-1"></div>
        <div class="col-5">
            <div class="form-group">
                <label>开始时间：</label>
                <input type="time" class="form-control" name="start[]" value="" required placeholder="请输入开始时间" />
            </div>
        </div>
        <div class="col-5">
            <div class="form-group">
                <label>结束时间：</label>
                <input type="time" class="form-control" name="end[]" value="" required placeholder="请输入结束时间" />
            </div>
        </div>
        <div class="col-1"><span class="card-tools" style="color:red;cursor: pointer;" onclick="del(this);">删除</span></div>

    </div>
</div>

<script>
    window.onEpiiInit(function() {

        $("#addval").click(function(){
            let tplhtml = $("#tpl").html();
            $("#vallist .card-body").append(tplhtml);
        });

    });

    function del(target){
        if(confirm('确定要删除吗？')){
            // ajax 删除
            $(target).parents("div.onerow").remove();
        }else{
            return false;
        }
    }

</script>